﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="QuestionsManage.aspx.cs"
    Inherits="OA.Exam.QuestionsManage" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>维护题库</title>
    <link href="../Themes/Default/Style.css" rel="stylesheet" type="text/css" />
    
    <script type="text/javascript" language="javascript">
        function checkAll() {
            var Myform = window.document.forms[0];
            for (var i = 0; i < Myform.elements.length; i++) {
                var c = Myform.elements[i].type;
                if (c == "checkbox" && document.all.chball.checked) {
                    Myform.elements[i].checked = true;
                }
                else {
                    Myform.elements[i].checked = false;
                }
            }
        }

        function GoSelect() {
            if (event.srcElement.tagName.toUpperCase() == "A") {
                return false;
            }
            else {
                return true;
            }

        }

        function IsCheck() {
            var Myform = window.document.forms[0];
            var k = 0;
            for (var i = 0; i < Myform.elements.length; i++) {
                var c = Myform.elements[i].type;
                var d = Myform.elements[i].id;
                if (c == "checkbox" && d.indexOf("TreeView") != -1 && Myform.elements[i].checked == true) {
                    k++;
                }
            }
            if (k == 0) {
                document.getElementById("spanPrompt").innerHTML = "您没有选择分组";
                return false;
            }
            else {
                return true;
            }
        }
    </script>

</head>
<body>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <div>
        <table width="100%">
            <tr>
                <td colspan="2" class="TitleZone">
                    维护题库
                    <input id="HiddenQid" type="hidden" runat="server" />
                </td>
            </tr>
            <tr>
                <td colspan="2" align="center">
                    <asp:Label ID="LabPrompt" runat="server" Text="" ForeColor="Red"></asp:Label>
                </td>
            </tr>
            <tr>
                <td style="width: 80%">
                    <asp:Button ID="BtnTrigger" runat="server" Text="触发Ajax控件" Width="0px" Height="0px"/>
                </td>
                <td style="width: 20%">
                    <asp:Button ID="BtnImport" runat="server" Text="批量导入" CssClass="closebtn" />
                    <asp:Button ID="BtnAdd" runat="server" Text="新增" CssClass="closebtn" OnClick="BtnAdd_Click" />
                    <asp:Button ID="BtnDelete" runat="server" Text="删除" CssClass="closebtn" OnClientClick="return confirm('确定要删除所选题目吗？')"
                        OnClick="BtnDelete_Click" />
                </td>
            </tr>
            <tr>
                <td>
                    &nbsp;&nbsp;题型：
                    <asp:DropDownList ID="DdlType" runat="server" CssClass="" AppendDataBoundItems="true"
                        DataTextField="TypeName" DataValueField="TypeId">
                        <asp:ListItem Value="-1">-请选择-</asp:ListItem>
                    </asp:DropDownList>
                    &nbsp;&nbsp;所属分组：
                    <asp:DropDownList ID="DdlGroup" runat="server" CssClass="" AppendDataBoundItems="true"
                        DataTextField="GroupName" DataValueField="GroupId">
                        <asp:ListItem Value="-1">-请选择-</asp:ListItem>
                    </asp:DropDownList>
                    &nbsp;&nbsp;题目：
                    <asp:TextBox ID="TxtSubject" runat="server" CssClass="inputText"></asp:TextBox>
                    &nbsp;&nbsp;<asp:Button ID="BtnSearcn" runat="server" Text="查询" CssClass="closebtn"
                        OnClick="BtnSearcn_Click" />
                </td>
            </tr>
            <tr>
                <td colspan="2">
                    <asp:GridView ID="GridViewQuestions" runat="server" AutoGenerateColumns="false" CssClass="GridViewStyle"
                        Width="100%" AllowPaging="true" EmptyDataText="暂无题目" DataKeyNames="QuestionId"
                        OnPageIndexChanging="GridViewQuestions_PageIndexChanging" OnRowCommand="GridViewQuestions_RowCommand">
                        <Columns>
                            <asp:TemplateField>
                                <HeaderTemplate>
                                    <input id="chball" type="checkbox" onclick="checkAll()" />
                                </HeaderTemplate>
                                <ItemTemplate>
                                    <asp:CheckBox ID="ChbCheck" runat="server" />
                                </ItemTemplate>
                                <HeaderStyle Width="4%" HorizontalAlign="Left" />
                                <ItemStyle Width="4%" />
                            </asp:TemplateField>
                            <asp:BoundField DataField="TypeName" HeaderText="题型" ItemStyle-Width="10%">
                                <ItemStyle Width="10%"></ItemStyle>
                            </asp:BoundField>
                            <asp:BoundField DataField="Subject" HeaderText="题目" ItemStyle-Width="50%">
                                <ItemStyle Width="50%"></ItemStyle>
                            </asp:BoundField>
                            <asp:TemplateField HeaderText="操作">
                                <ItemTemplate>
                                    <asp:LinkButton ID="LbtnEdit" runat="server" CssClass="" CommandName="EditQuestion">修改</asp:LinkButton>|
                                    <asp:LinkButton ID="LbtnDelete" runat="server" CssClass="" OnClientClick="return confirm('确定要删除吗？')"
                                        CommandName="DeleteQuestion">删除</asp:LinkButton>|
                                    <asp:LinkButton ID="LbtnSetGroup" runat="server" CssClass="" CommandName="SetQuestion">设置分组</asp:LinkButton>
                                </ItemTemplate>
                                <ItemStyle Width="20%" HorizontalAlign="Center" />
                            </asp:TemplateField>
                            <asp:HyperLinkField DataNavigateUrlFields="questionId" DataNavigateUrlFormatString="SetQuestionItems.aspx?qId={0}"
                                Text="设置题目选项" HeaderText="设置" ItemStyle-HorizontalAlign="Center">
                                <ItemStyle HorizontalAlign="Center"></ItemStyle>
                            </asp:HyperLinkField>
                        </Columns>
                        <FooterStyle CssClass="GridViewFooterStyle" />
                        <RowStyle CssClass="GridViewRowStyle" />
                        <SelectedRowStyle CssClass="GridViewSelectedRowStyle" />
                        <PagerStyle CssClass="GridViewPagerStyle" />
                        <AlternatingRowStyle CssClass="GridViewAlternatingRowStyle" />
                        <HeaderStyle CssClass="GridViewHeaderStyle" />
                    </asp:GridView>
                </td>
            </tr>
        </table>
        <cc1:ModalPopupExtender ID="ModalPopupExtender1" runat="server" DynamicServicePath=""
            Enabled="True" TargetControlID="BtnTrigger" PopupControlID="Panel1" BackgroundCssClass="modalBackground"
            DropShadow="false" Drag="true" CancelControlID="BtnClose">
        </cc1:ModalPopupExtender>
    </div>
            <asp:Panel ID="Panel1" runat="server" Style="display: none; width:40%; text-align:left;" CssClass="modalPopup">
            <table width="98%" border="0" cellspacing="1" style="border-collapse: collapse; border-color: #0099cc;">
                <tr>
                    <td style="width:100%">
                        请设置题目的分组：
                    </td>
                </tr>
                <tr>
                    <td>
                        <span id="spanPrompt" style="color:Red; display:block;"></span>
                    </td>
                </tr>
                <tr>
                    <td>
                        <asp:TreeView ID="TreeView1" runat="server" ShowCheckBoxes="All" 
                            ExpandDepth="FullyExpand">
                        </asp:TreeView>
                    </td>
                </tr>
                <tr>
                    <td>
                        <asp:Button ID="BtnOk" runat="server" Text="确定" OnClick="BtnOk_Click" OnClientClick="return IsCheck()" />
                        <asp:Button ID="BtnClose" runat="server" Text="关闭" />
                    </td>
                </tr>
            </table>
        </asp:Panel>
    </form>
</body>
</html>
